<template>
	<view class="news-detail wm">
		<block v-if="news">
			<view class="title">{{news.title}}</view>
			<view class="auther">
				<block v-if="news.photo">
					<image class="auther_photo" :src="portUrl_ + news.photo"></image>
				</block>
				
				<view class="auther_time">
					<view class="auther_name">{{news.author}}</view>
				    <view class="create_time">{{news.create_time}}</view>
				</view>
				
			</view>
			<view class="content">
				<p  v-html="news.content"></p>
			</view>
		</block>
		<block v-else>
			<no-data></no-data>
		</block>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				queryObj:{
					newsid:28,
					
				},
				news:{}
			};
		},
		onLoad(options){
			//复制请求对象传来的参数
			this.queryObj.newsid = options.newsid || ''
			this.getNewsDetail();
		},
		computed:{
			portUrl_: function(){
				return getApp().globalData.portUrl;
			}
		},
		methods:{
			/**
			 * 获取当前新闻的详细内容
			 */
			async getNewsDetail(){
				const {data:res} = await uni.$http.post("newss/getNewsDetail",this.queryObj);
				//请求失败
				if(res.meta.status !== 1) return uni.$showMsg();
				//请求成功
				this.news = res.data;
			}
		}
		
	}
</script>

<style lang="scss">

.wm{
	width: 90%;
	margin:0 auto;
}
.news-detail{
	position: relative;
	.title{
		position: relative;
		margin:40rpx auto;
		font-weight: bold;
		font-size:45rpx;
	}
	.auther{
		display: flex;
		justify-content: flex-start;
		margin-bottom: 30rpx;
		.auther_photo{
			height: 60rpx;
			width:60rpx;
			border-radius: 50%;
			display: flex;
			justify-content: center;
			align-items: center;
		}
		.auther_time{
			margin-left:15rpx;
			.auther_name{
				font-size: 25rpx;
				color:#515151;
			}
			.create_time{
				font-size: 20rpx;
				color:#515151;
			}
		}
		
	}
	.content{
		padding:20rpx;
	}
}
</style>
